package com.eudon.design_pattern.creational.singleton;

/**
 * @author eudon
 * @description 双重检查单例
 * @date 2025/9/1
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class DoubleCheckSingleton {
    private static DoubleCheckSingleton instance;
    private DoubleCheckSingleton() {}

    public static DoubleCheckSingleton getInstance() {
        if (instance == null) {
            synchronized (DoubleCheckSingleton.class) {
                if (instance == null) {
                    return instance = new DoubleCheckSingleton();
                }
            }
        }
        return instance;
    }
}
